package com.hskn.hss.module.videofile.controller;

import com.github.pagehelper.Page;
import com.hskn.hss.core.controller.BaseController;
import com.hskn.hss.entity.AjaxResult;
import com.hskn.hss.module.videofile.service.IVideoFileService;
import com.hskn.hss.module.videofile.to.VideoFileTO;
import com.hskn.hss.module.videofile.vo.VideoFileVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 录像文件
 *
 * @author lny
 * @date 2021-11-18
 */
@Api(tags = {"-video_file"}, description = "录像文件")
@RestController
@Slf4j
@RequestMapping("/hss/videoFile")
public class VideoFileController extends BaseController {

    @Autowired
    private IVideoFileService videoFileService;

    /**
     * 查询
     */
    @ApiOperation(value = "录像文件查询", notes = "录像文件查询")
    @ApiResponses({@ApiResponse(code = 200, message = "ok", response = VideoFileVO.class)})
    @PostMapping("/list")
    public AjaxResult list(@RequestBody @Validated VideoFileTO videoFileTO) {
        try {
            Page page = startPage(videoFileTO.getPage(), videoFileTO.getSize());
            return AjaxResult.success(getDataTable(videoFileService.list(videoFileTO), page.getTotal()));
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            return AjaxResult.fail(e.getMessage());
        }
    }

}
